package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.Certification;
import com.shrcl.engineerprocess.domain.Engineer;
import com.shrcl.engineerprocess.domain.EngineerCapability;
import com.shrcl.engineerprocess.domain.ProductItemCode;
import com.shrcl.engineerprocess.domain.impl.CertificationImpl;
import com.shrcl.engineerprocess.domain.impl.EngineerImpl;
import com.shrcl.engineerprocess.domain.impl.ProductItemCodeImpl;
import com.shrcl.engineerprocess.domain.proxy.EngineerCapabilityProxy;
import com.shrct.businessprocess.product.RCBrand;
import com.shrct.businessprocess.product.impl.RCBrandImpl;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("ENGINEERCAPABILITY_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "engineercapability")
public class EngineerCapabilityImpl extends BaseModelObject implements EngineerCapability {
  public EngineerCapabilityImpl() {
    super();
  }
  
  public EngineerCapabilityImpl(final Engineer engineer) {
    super();
    this.engineer = engineer;
  }
  
  @JoinColumn(name = "engineer_id")
  @ManyToOne(targetEntity = EngineerImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private Engineer engineer;
  
  public Engineer getEngineer() {
    return this.engineer;
  }
  
  public EngineerCapability setEngineer(final Engineer engineer) {
    this.engineer = engineer;
    return this;			
    
  }
  
  @JoinColumn(name = "certification_id")
  @ManyToOne(targetEntity = CertificationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private Certification certification;
  
  public Certification getCertification() {
    return this.certification;
  }
  
  public EngineerCapability setCertification(final Certification certification) {
    this.certification = certification;
    return this;			
    
  }
  
  @JoinColumn(name = "productBrand_id")
  @ManyToOne(targetEntity = RCBrandImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBrand productBrand;
  
  public RCBrand getProductBrand() {
    return this.productBrand;
  }
  
  public EngineerCapability setProductBrand(final RCBrand productBrand) {
    this.productBrand = productBrand;
    return this;			
    
  }
  
  @JoinColumn(name = "productItem_id")
  @ManyToOne(targetEntity = ProductItemCodeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private ProductItemCode productItem;
  
  public ProductItemCode getProductItem() {
    return this.productItem;
  }
  
  public EngineerCapability setProductItem(final ProductItemCode productItem) {
    this.productItem = productItem;
    return this;			
    
  }
  
  private Integer currentLevel;
  
  public Integer getCurrentLevel() {
    return this.currentLevel;
  }
  
  public EngineerCapability setCurrentLevel(final Integer currentLevel) {
    this.currentLevel = currentLevel;
    return this;			
    
  }
  
  private Integer expectedLevel;
  
  public Integer getExpectedLevel() {
    return this.expectedLevel;
  }
  
  public EngineerCapability setExpectedLevel(final Integer expectedLevel) {
    this.expectedLevel = expectedLevel;
    return this;			
    
  }
  
  public static EngineerCapability create(final Engineer engineer, final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.EngineerCapability engineerCapability = new com.shrcl.engineerprocess.domain.impl.EngineerCapabilityImpl(
    	engineer
    );
    objectFactory.create(engineerCapability);
    return engineerCapability;			
    
  }
  
  public static EngineerCapability createEngineerCapabilityImpl(final Engineer engineer, final IObjectFactory objectFactory, final Procedure1<EngineerCapability> init) {
    com.shrcl.engineerprocess.domain.EngineerCapability engineerCapability = new com.shrcl.engineerprocess.domain.impl.EngineerCapabilityImpl(
    	engineer
    );
    objectFactory.create(engineerCapability);
    init.apply(engineerCapability);
    
    return engineerCapability;			
    
  }
  
  public EngineerCapabilityProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.EngineerCapabilityProxy proxy = new com.shrcl.engineerprocess.domain.proxy.EngineerCapabilityProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
